/*************************************************************************
	> File Name: P1015.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2024-12-13 11:09:59
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

ll to_ten(string num, ll base) {
    int h = 0, ret = 0;
    for (int i = num.size() - 1; i >= 0; i--) {
        if (num[i] >= 'A' && num[i] <= 'F') {
            ret += (num[i] - 'A' + 10) * pow(base, h);
        } else {
            ret += (num[i] - '0') * pow(base, h);
        }
        h += 1;
    }
    return ret;
}

int check(ll &num, ll base) {
    ll x = num, temp = 0;
    while (x) {
        temp = temp * base + x % base;
        x /= base;
    }
    x = num;
    num += temp;
    return temp == x;
}

int main() {
    int base;
    string num;
    cin >> base >> num;
    int cnt = 0, flag = 1;
    ll val = to_ten(num, base);
    while (flag && cnt <= 30) {
        cnt++;
        if (check(val, base)) {
            flag = 0;
        }
    }
    if (flag) {
        cout << "Impossible!" << endl;
    } else {
        cout << "STEP=" << cnt - 1 << endl;
    }
    return 0;
}
